//节流函数,n秒内只触发一次
function throttle(fn,wait){
    let timer=null;
    return function(){
        if(!timer){
            timer=setTimeout(()=>{
                timer=null;
                fn.apply(this,...arguments);
            },wait)
        }
    }
}